< previous page page_83 next page >

Page 83
For the example, you'll open the database for exclusive use. Modify the OpenDB procedure so that it sets the Exclusive property to True. Your code should look like the following code:
Public Sub OpenDB()
   Dim cDBName As String    ' declare a string variable
   Dim cTblName As String   ' declare a string variable
   Dim bExclusive As Boolean ' declare true/false var
   '
   cDBName = "c:\tysdbvb5\source\data\books5.mdb" ' point to database
cTblName = "Authors" ' point to authors table
   bExclusive = True ' set to exclusive open
   '
   Data1.DatabaseName = cDBName ' set database property
   Data1.RecordSource = cTblName ' set recordsource property
   Data1.Exclusive = bExclusive
   '
   Data1.Refresh ' update data control properties
End Sub
warning.gif
When you open the database with Exclusive set to True, no other programs that access the database can be run without errors until you close the database. Use the Exclusive property sparingly!

The ReadOnly property opens the database with read rights only. You will not be allowed to make any changes, additions, or deletions in any table while you have the database open in read-only mode. This is handy when you are using the data for creating a report or for display purposes only. (Read-only mode is faster, too.)
Note.gif
Don't confuse the Exclusive property and the ReadOnly property; they are not the same! The Exclusive property makes sure that no one else can access the database while you have it open. The ReadOnly property makes sure that your program cannot update the database while you have it open. The Exclusive property affects everyone who wants to access the database. The ReadOnly property affects only the person running your program.

Again, for this example, you'll open the file as read-only. Make changes to the OpenDB procedure to include variables that set the ReadOnly property to True. When you are done, your code should look something like the following code:
Public Sub OpenDB()
   Dim cDBName As String    ' declare a string variable
   Dim cTblName As String   ' declare a string variable

 
< previous page page_83 next page >

If you like this book, buy it!